package jsu.yym.tiktok.server;

import jsu.yym.tiktok.server.SnowFlake;
import org.springframework.stereotype.Component;

@Component
public class idUtil {

    //生成8位账号
    public String creatID()
    {
        SnowFlake idWorker = new SnowFlake(0, 0);
        long id = idWorker.nextId();
        while(id>99999999)
        {
            id= id/10;
        }
        String ID = String.valueOf(id);
        return ID;
    }


    //生成六位验证码
    public String creatCode()
    {
        SnowFlake idWorker = new SnowFlake(0, 0);
        long id = idWorker.nextId();
        while(id>999999)
        {
            id= id/10;
        }
        String ID = String.valueOf(id);
        return ID;
    }

    //生成四位验证码
    public int creatCodeFour()
    {
        SnowFlake idWorker = new SnowFlake(0, 0);
        long id = idWorker.nextId();
        while(id>9999)
        {
            id= id/10;
        }
        int ID = (int) id;
        return ID;
    }



    //生成9位验证码
    public int creatCodeTen()
    {
        SnowFlake idWorker = new SnowFlake(0, 0);
        long id = idWorker.nextId();
        while(id>999999999)
        {
            id= id/10;
        }
        int ID = (int) id;
        return ID;
    }


}
